package vld

import (
	sqlc "bp/db/sqlc"
	"bp/internal/util"
)

// IsPromotionStatus check string is em_promotion_status
func IsPromotionStatus(v string) (success bool) {
	switch sqlc.EmPromotionStatus(v) {
	case sqlc.EmPromotionStatusDraft, sqlc.EmPromotionStatusPublished,
		sqlc.EmPromotionStatusPaused, sqlc.EmPromotionStatusFinished,
		sqlc.EmPromotionStatusClosed:
		success = true
	}
	return
}

// IsPromotionStatusArray check []string is []em_promotion_status
func IsPromotionStatusArray(v []string, emptyIsValid bool) (success bool) {
	if emptyIsValid && len(v) == 0 {
		success = true
		return
	}
	success = util.AllString(v, func(s string) bool {
		return IsPromotionStatus(s)
	})
	return
}
